#include "LED_Galloping.h"

LED_Galloping::LED_Galloping(int firstLedPin, int secondLedPin, int thirdLedPin){
 pins[0] = firstLedPin;
 pins[1] = secondLedPin;
 pins[2] = thirdLedPin;
}

//从左往右依次点亮然后依次灭
void LED_Galloping::galloping_1(){
  unsigned char j;
  for(j = 0; j < pinNum; j++){
    digitalWrite(pins[j], HIGH);
    delay(100);
  }
  
  for(j = 0; j < pinNum; j++){
    digitalWrite(pins[j], LOW);
    delay(100);
  }
}

//从右往左依次点亮然后依次灭
void LED_Galloping::galloping_2(){
  unsigned char j;
  for(j = pinNum; j >0; j--){
    digitalWrite(pins[j], HIGH);
    delay(100);
  }
  digitalWrite(pins[0], HIGH);
  delay(100);
  
  for(j = pinNum; j >0; j--){
    digitalWrite(pins[j], LOW);
    delay(100);
  }
  digitalWrite(pins[0], LOW);
  delay(100);
}

//从两边向中间
void LED_Galloping::galloping_3(){
  unsigned char i;
  unsigned char j = pinNum;
  for(i = 0;i < j;i++){
    digitalWrite(pins[i],HIGH);
    digitalWrite(pins[j-1],HIGH);
    delay(300);
    j--;
  }

  for(;i>0;i--){
    digitalWrite(pins[i],LOW);
    digitalWrite(pins[j-1],LOW);
    delay(300);
    j++;
  }
  digitalWrite(pins[0],LOW);
  digitalWrite(pins[pinNum-1],LOW);
  delay(300);
}
